package Mysql

import (
	"database/sql"
	"fmt"

	_ "github.com/go-sql-driver/mysql"
	"github.com/jmoiron/sqlx"
)

var Db *sqlx.DB

func InitMysqlFunc() {
	dsn := "root:123456@tcp(127.0.0.1:3306)/bluebell"
	var err error
	Db, err = sqlx.Connect("mysql", dsn)
	if err != nil {
		fmt.Printf("open sql failed")
		panic(err)
	}

	err = Db.Ping()
	if err != nil {
		panic(err)
	}

	fmt.Printf("init mysql success\n")
}

type MysqlStruc struct {
	Name string
	Age  int
}

func (mql *MysqlStruc) AddFunc(Db *sql.DB) {

}

func (mql *MysqlStruc) SubFunc(Db *sql.DB) {

}

func Close() {
	Db.Close()
}
